//
//  BasicClassListCell.m
//  JPWords
//
//  Created by 梁淑婷 on 2024/6/1.
//

#import "BasicClassListCell.h"

@interface BasicClassListCell()

@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UIView *line;

@end

@implementation BasicClassListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    __weak typeof(self)self_weak_ = self;
    self.backgroundColor = KbgColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = JPUIFontPingFangSCMedium(14);
    self.titleLabel.textColor = KFontBlackColor;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@12);
        make.right.mas_equalTo(@-12);
        make.height.mas_equalTo(@20);
        make.centerY.mas_equalTo(self_weak_.contentView);
    }];
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = KThemeColor;
    self.line.layer.cornerRadius = 2;
    self.line.layer.masksToBounds = YES;
    [self.contentView addSubview:self.line];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@-2);
        make.width.mas_equalTo(@4);
        make.centerY.mas_equalTo(self_weak_.contentView);
        make.height.mas_equalTo(@22);
    }];
    self.line.hidden = YES;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}

-(void)setIsSel:(BOOL)isSel{
    _isSel = isSel;
    if(isSel == YES){
        self.line.hidden = NO;
        self.backgroundColor = [UIColor whiteColor];
    }else{
        self.line.hidden = YES;
        self.backgroundColor = KbgColor;
    }
}

@end
